package com.mia.props.common.entities;

import net.minecraft.block.Block;
import net.minecraft.block.BlockCauldron;

public class TileFaucet extends TileParticleEmitterSwitchable {
   public void updateEntity() {
      if (this.isRunning) {
         if (!this.worldObj.isRemote && this.worldObj.getWorldInfo().getWorldTotalTime() % 4L == 0L) {
            int deltaX = 0;
            int deltaZ = 0;
            if (this.tileParams.containsKey("tile_outward") && Boolean.valueOf((String)this.tileParams.get("tile_outward"))) {
               deltaX = (new int[]{0, 1, 0, -1})[this.rotation / 4];
               deltaZ = (new int[]{-1, 0, 1, 0})[this.rotation / 4];
            }

            Block blockBelow = this.worldObj.getBlock(this.xCoord + deltaX, this.yCoord - 1, this.zCoord + deltaZ);
            if (blockBelow instanceof BlockCauldron) {
               if (this.worldObj.getBlockMetadata(this.xCoord + deltaX, this.yCoord - 1, this.zCoord + deltaZ) == 0) {
                  this.worldObj.setBlockMetadataWithNotify(this.xCoord + deltaX, this.yCoord - 1, this.zCoord + deltaZ, 1, 2);
               } else {
                  ((BlockCauldron)blockBelow).fillWithRain(this.worldObj, this.xCoord + deltaX, this.yCoord - 1, this.zCoord + deltaZ);
               }
            }
         }

         super.updateEntity();
      }
   }
}
